package com.web.netalbum.service.impl;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.web.netalbum.bean.Photo;
import com.web.netalbum.dao.PhotoDao;
import com.web.netalbum.dao.impl.PhotoDaoImpl;
import com.web.netalbum.service.PhotoService;

public class PhotoServiceImpl implements PhotoService {
	private PhotoDao pDao=new PhotoDaoImpl();
	@Override
	public List<Photo> findPhotosByAlbumId(int id,int count) {
		
		return pDao.findAllPhotoByAlbumId(id,count);
	}
	@Override
	public Set<Photo> search(String key) {
		String[] keys = key.split("\\+");
		Set<Photo> photos=new HashSet<>();
		for (String string : keys) {
			List<Photo> plist=pDao.findPhotoByKeyword(string);
			if(plist!=null){
				for (Photo photo : plist) {
					photos.add(photo);
				}
			}
		}
		return photos;
	}
	@Override
	public List<Photo> findPhotosByAlbumId(int id) {
		
		return pDao.findPhotosByAlbumId(id);
	}
	@Override
	public Photo findPhotoById(String photoId) {
		// TODO Auto-generated method stub
		return pDao.findPhotoById(photoId);
	}
	@Override
	public List<Photo> findPhotos(int i) {
		// TODO Auto-generated method stub
		return pDao.findPhotos(i);
	}
	@Override
	public List<Photo> findPhotosByAidAndUid(int aid, String uid) {
		// TODO Auto-generated method stub
		return pDao.findPhotosByAidAndUid(aid, uid);
	}
	@Override
	public List<Photo> findAllPhotosByUserId(String id) {
		// TODO Auto-generated method stub
		return pDao.findAllPhotosByUserId(id);
	}
	@Override
	public void savePhotos(Object[][] args) {
		pDao.savePhotos(args);
		
	}

}
